import scala.actors.Actor
import scala.actors.Actor._


/**
 * Represents the Airport (?), functioning as the actor generating Passenger and
 * Bag messages.
 * @author Samuel Nelson, Robert Vrooman, James Fitzgerald, Gabriel Marcano
 */
class Driver(passengers: Array[Passenger], lineCount : Int) extends Actor {

  val docCheck = new DocumentCheck(lineCount, new Jail)
  docCheck.start
  println("Driver is sending the first Startup to the DocumentCheck.")
  docCheck ! Startup

  def act() {
    for (val passenger <- passengers) {
      docCheck ! passenger
    }
  }
}

/**
 * Main entry point for the simulation
 */
object Main {
  def main(args: Array[String]) {
    var pasCount = 10;
    if (args.length >= 2)
    {
      pasCount = Integer.valueOf(args(1)).intValue;
    }
    
    val passengers = new Array[Passenger](pasCount)
    for (i <- 0 to pasCount-1) {
      passengers(i) = new Passenger(i)
    }
    
    if (args.length >= 1)
    {
      val driver = new Driver(passengers,
                              Integer.valueOf(args(0)).intValue).start
    }
    else
    {
      val driver = new Driver(passengers, 3).start
    }
    
  }
}